﻿namespace h9

{

    public interface A

    {

        double Area();

    }



    public interface B

    {

        abstract void SetColor(string c);

    }



    public interface C : A, B

    {

        void Volume();

    }



    public class Cylinder : C

    {

        private double _radius;

        private double _height;

        private string _color;



        public Cylinder(double radius, double height, string color)

        {

            _radius = radius;

            _height = height;

            _color = color;

        }



        public double Radius

        {

            get { return _radius; }

            set { _radius = value; }

        }



        public double Height

        {

            get { return _height; }

            set { _height = value; }

        }



        public string Color

        {

            get { return _color; }

            set { _color = value; }

        }



        public double Area()

        {

            return Math.PI * _radius * _radius;

        }



        public void SetColor(string c)

        {

            _color = c;

        }



        public void Volume()

        {

            double volume = Area() * _height;

            Console.WriteLine($"圆柱体体积: {volume:F2}");

        }



        public void DisplayInfo()

        {

            Console.WriteLine($"圆柱体信息:");

            Console.WriteLine($"底圆半径: {_radius}");

            Console.WriteLine($"高度: {_height}");

            Console.WriteLine($"颜色: {_color}");

            Console.WriteLine($"底面积: {Area():F2}");



        }

    }



    internal class Program

    {

        public static void Main(string[] args)

        {

            Cylinder cylinder = new Cylinder(3.5, 10, "蓝色");



            cylinder.DisplayInfo();



            cylinder.Volume();



            cylinder.SetColor("红色");

            Console.WriteLine($"修改后的颜色: {cylinder.Color}");



            C c = cylinder;

            Console.WriteLine("通过接口C调用方法:");

            Console.WriteLine($"底面积: {c.Area():F2}");

            c.SetColor("绿色");

            Console.WriteLine($"再次修改后的颜色: {cylinder.Color}");

            c.Volume();

        }

    }

}

